export const decode = function(encoded, translations)
{
	function isEmpty(value) {
		if (typeof value === 'undefined' || value === null || (typeof value === 'string' && value.trim().length === 0))
		{
		return true;
		} 
		else if (typeof value === 'object') 
		{
		return Object.keys(value).length === 0 && value.constructor === Object;
		} 
		else if (Array.isArray(value)) {
			return value.length === 0;
		} 
		else 
		{
		return false;
		}
	}
	const exceptions = ['groupId', 'service', 'formatSize', 'ca']
	const suffix = 'Id';
	let unique = []
	let result = []
	let tempObj = {}
	for(let groupItem of encoded)
	{
		for(let key of Object.keys(groupItem))
		{
			if(!exceptions.includes(key) && key.endsWith(suffix))
			{
				tempObj[key] = isEmpty(translations[groupItem[key]]) ? groupItem[key] : translations[groupItem[key]]
			}
			else
			{
				tempObj[key] =groupItem[key]
			}
			if(!unique.includes(groupItem[key]) && !isEmpty(groupItem[key]) && key.endsWith(suffix))
			{
				unique.push(groupItem[key])
			}
		}
		result.push(tempObj)
		tempObj = {}
	}
}